import { RefObject } from 'react';
import { Message } from '@douyinfe/semi-foundation/lib/es/chat/foundation';

// 智能体信息类型
export interface AgentInfo {
  id: string;
  mark: string;
  sessionId: string;
  isStreaming: number;
  status?: 'active' | 'error';
}

// 对话窗口位置类型
export interface ChatPosition {
  top?: number;
  left?: number;
  bottom?: number;
  right?: number;
}

// 组件引用方法类型
export interface ChatRef {
  sendMessage: (content: string) => Promise<void>;
  clearHistory: () => void;
  changeAgent: (newAgentId: string) => Promise<boolean>;
  getHistory: () => Message[];
  changeSession: (sessionId: string) => Promise<boolean>;
  setHistoryMessages?: (messages: Message[]) => void;
  newChat?: () => void;
}

// 组件属性类型
export interface ChatProps {
  sessionId?: string;                                  // 显示的会话ID
  agentId: string;                                    // 智能体标识
  mode?: 'div' | 'dialog';                           // 显示模式
  initialCollapsed?: boolean;                         // 初始折叠状态
  position?: ChatPosition;                            // 弹窗位置
  onMessage?: (message: Message, sessionId: string, chatId: string, params: any) => void;         // 消息回调
  onRenderComplete?: () => void;                      // 渲染完成回调
  onStreamMessage?: (content: string, done: boolean) => void;  // 流式消息回调
  onClose?: () => void;                              // 关闭回调
  bindRef?: (ref: RefObject<ChatRef>) => void;       // 绑定ref方法
  className?: string;                                // 自定义类名
  style?: React.CSSProperties;                       // 自定义样式
  getAdditionalParams?: () => any;                  // 获取额外参数的方法
  promptName?: string;                             // prompt名称
  functionName?: string;                           // function名称  
  renderWelcome?: () => React.ReactNode;            // 欢迎语渲染钩子
  renderHintBox?: () => React.ReactNode;            // 提示框渲染钩子
  hideChat?: boolean;                              // 隐藏聊天组件
}

export const message_type = {
  USER: 'user',
  ASSISTANT: 'assistant',
  SYSTEM: 'system',
}

export const default_empty_message = '暂无内容';
export const default_error_message = '获取消息内容失败';
